package com.finance.console.entity;

import java.util.Map;

public class AnalysisResult {
    private String period;
    private String topConsumeType; // 最高消费类型
    private Map<String, Double> consumeRatio; // 消费占比（如：餐饮:30.5%）
    private boolean isOverBudget; // 是否超预算

    // Getter/Setter
    public String getPeriod() { return period; }
    public void setPeriod(String period) { this.period = period; }
    public String getTopConsumeType() { return topConsumeType; }
    public void setTopConsumeType(String topConsumeType) { this.topConsumeType = topConsumeType; }
    public Map<String, Double> getConsumeRatio() { return consumeRatio; }
    public void setConsumeRatio(Map<String, Double> consumeRatio) { this.consumeRatio = consumeRatio; }
    public boolean isOverBudget() { return isOverBudget; }
    public void setOverBudget(boolean overBudget) { isOverBudget = overBudget; }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(String.format("===== %s 消费分析 =====\n", period));
        sb.append(String.format("最高消费类型：%s\n", topConsumeType));
        sb.append("消费占比：\n");
        consumeRatio.forEach((type, ratio) -> sb.append(String.format("  %s：%.1f%%\n", type, ratio)));
        sb.append(String.format("是否超预算：%s\n", isOverBudget ? "是" : "否"));
        return sb.toString();
    }
    // 支出分类占比（分类名称 → 占比比例，如"餐饮"→0.3表示30%）
    private Map<String, Double> categoryRatio;
    // 预算执行率（如0.85表示85%）
    private double budgetExecutionRate;

    // 必须添加与调用匹配的getter方法
    public Map<String, Double> getCategoryRatio() {
        return categoryRatio;
    }

    public double getBudgetExecutionRate() {
        return budgetExecutionRate;
    }

    // 可选：添加setter方法（用于Service层赋值）
    public void setCategoryRatio(Map<String, Double> categoryRatio) {
        this.categoryRatio = categoryRatio;
    }

    public void setBudgetExecutionRate(double budgetExecutionRate) {
        this.budgetExecutionRate = budgetExecutionRate;
    }
}